package org.robotfish.geometry;

import static org.junit.Assert.*;

import org.ejml.simple.SimpleMatrix;
import org.junit.Test;
import org.robotfish.utils.SVGDocument;

public class TransformTest {
	
	@Test
	public void testTransformTrivial() {
		SimpleMatrix m1 = new SimpleMatrix(new double[][] {{0.2}, {0.5}, {1.0}});
		SimpleMatrix m2 = TransformPoints.toRelative(m1, 0.5);
		
		SimpleMatrix m2expected = new SimpleMatrix(new double[][] {{0.4152293}, {0.3429062}, {1.0}});
		assertTrue( m2.isIdentical(m2expected, 1e-5));
		
		m2 = TransformPoints.toRelative(m1, 0);
		assertTrue( m2.isIdentical(m1, 1e-8) );
	}
	
	@Test
	public void testTransformXY() {
		
		TransformationXY t = new TransformationXY(0);
		t.addLevels(new double[]{-0.1,0, 0.1});		
//		t.addLevels(new double[]{0.1});		

		SimpleMatrix ray = new SimpleMatrix(new double[][] {{0.2}, {0}, {Math.PI*0.25}});
		t.addBend(0, 0.2, ray, 0.08);

		//create content recursively
		SVGDocument doc = t.toSVGDocument();
//		doc.units = true;
		doc.writeToFile("temp/test.svg");
		
		//System.out.println(t.toString());
//		SVGDocument.stringToFile( "temp/test.svg", t.toString() );
		
		/** Mart
		file:///D:/Users/Mart/workspace/fishrobot/robotfish/temp/test.svg
		**/
//		t.toString();
		
		
	}
	

}
